<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<div id="app">
  <cpn></cpn>
</div>
<template id="cpn">
  <div>
    <p>我是子组件</p>
    <button @click="btnClick">按钮</button>
    <ccpn></ccpn>
  </div>
</template>
<template id="ccpn">
  <div>
    <p>我是小组件</p>
    <button @click="smallClick">小组件按钮</button>
  </div>
</template>
<script src="../js/vue.js"></script>
<script>
  const cpn = {
    template: '#cpn',
    data() {
      return {
        name: '哈哈哈'
      }
    },
    methods: {
      showMessage() {
        console.log('我是子组件')
      },
      btnClick() {
        //  访问父组件
        console.log(this.$parent)
        // 访问根组件 $root
      }
    },
    props: {},
    components: {
      ccpn: {
        template: '#ccpn',
        methods: {
          smallClick () {
            console.log(this.$parent)
          }
        }
      }
    }
  }
  const app = new Vue({
    el: '#app',
    data: {
      message: "你好",
    },
    components: {
      cpn
    },
    methods: {}
  })
</script>
</body>
</html>
